package cn.doyens.bean;

import com.github.pagehelper.util.StringUtil;
import org.springframework.util.StringUtils;

public class Tool {
    private Tool tool;
    private Tool(){}
    public  Tool getTool(){
        if (tool==null){
            tool=new Tool();
        }
        return tool;
    }

    public static String compress(String s){
        String result="";
        if(StringUtils.isEmpty(s)){
            result="啥都不输入?";
        }else if(s.contains(" ")){
            result="别输入空格";
        }else {
            int length = s.length();
            System.out.println("字符串长度为:"+length);
            int a=0;
            for (int i = 1; i <=length; i++) {
                String[] split = s.split(s.substring(0, i));
                if (split.length==0){
                    System.out.println("切分到"+i);
                    a=i;
                    break;
                }
            }
            result=length/a+s.substring(0,a);
        }
        return result;
    }
}
